{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑皮肤</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">皮肤：</label>
                            <div class="layui-input-block">
                                <select name="pos_ps_id" lay-filter="role1" xm-select-search="" xm-select-radio="" xm-select-search-type="dl" disabled>
                                    <option value="">请选择皮肤</option>
                                    {volist name='skin' id='vo'}
                                    <option value="{$vo.pskin_id}" {$vo.pskin_id == $config.pos_ps_id ? 'selected' : ''}>{$vo.pskin_name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">配置选项：</label>
                            <div class="layui-input-block" id="demo5">

                            </div>
                        </div>


                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">备注：</label>
                            <div class="layui-input-block">
                                <textarea style="width: 578px;height: 50px" name="pos_describe" placeholder="情况描述">{$config.pos_describe}</textarea>
                            </div>
                        </div>

                        <input type="hidden" value="{$pos_id}" name="pos_id">
                        <input type="hidden" value="{$config.pos_psc_id}" name="pos_psc_id">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <!--<button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    var res_data = [];
    var demo5;
    var pos_ps_id; // 皮肤ID
    var pos_psc_id; // 皮肤配置ID
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('skinEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        });
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(role1)', function(data){
            pos_ps_id = data.value;
            $.ajax({
                url: "{:url('Privateorder/showConfig')}",
                type: 'post',
                dataType:'json',
                data:{'pos_ps_id':pos_ps_id},
                success:function (res) {
                    if(res.code == 200){
                        res_data = res.msg;
                        demo5 = xmSelect.render({
                            el: '#demo5',
                            language: 'zn',
                            data:res_data
                        });
                    }else{
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
<script>
    pos_ps_id = {$config.pos_ps_id}; // 皮肤ID
    pos_psc_id = $('input[name="pos_psc_id"]').val(); // 皮肤配置ID
    $.ajax({
        url: "{:url('Privateorder/showConfig')}",
        type: 'post',
        dataType:'json',
        data:{'pos_ps_id':pos_ps_id, 'pos_psc_id':pos_psc_id},
        success:function (res) {
            if(res.code == 200){
                res_data = res.msg;
                // 加载配置选项
                demo5 = xmSelect.render({
                    el: '#demo5',
                    language: 'zn',
                    data:res_data
                });
                // 加载被选中的配置选项
                demo5.setValue(res.data1);
            }else{
                wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
            }
        }
    });
</script>

</body>
</html>

